home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / gnustuff / minix / libsrc~1.z / libsrc~1 / std.h < prev    next >
Encoding:
C/C++ Source or Header  |  1989-12-28  |  10.3 KB  |  383 lines

  1. /*
  2.  * std.h
  3.  * An ANSI'ish prototype decl. file for the MINIX C library
  4.  * Only decls that do not need additional struct defs are in this
  5.  * file. The protos for decls that need some struct definitions
  6.  * are in the respective <*.h> files. This was done to avoid 
  7.  * #includ'ing the world here.
  8.  * Note: this file by no means fully conforms to the Ansi C docs
  9.  * in terms of types of args and returned values. I tried to come close
  10.  * without breaking/re-writing the minix (i have the ST version only)
  11.  * lib src. Any updates/fixes/suggestions are most welcome.
  12.  *
  13.  *     ++jrb bammi@dsrgsun.ces.cwru.edu or {decvax,sun}!cwjcc!dsrgsun!bammi
  14.  *
  15.  * Random Notes:
  16.  *    - A lot of the prototypes like malloc, read,write,fread,bcopy, mem etc
  17.  *       should really be specified as taking the type size_t for their
  18.  *      count arguement. This was not done as it would require quite a
  19.  *      bit of change to the library source and some of the system calls.
  20.  *
  21.  *    - When using Gnu CC -mshort (ie. 16 bit integers) one should be
  22.  *       aware that the `sizeof' operator yields a long and *not* an int.
  23.  *      What this means is calling malloc(sizeof(X)) is incorrect, and
  24.  *      will NOT do the right thing. Now if you have the prototype
  25.  *      `void *malloc(unsigned);' the compiler will coerce the
  26.  *      arguement in a `malloc(sizeof(X))' call correctly to an unsigined
  27.  *      int and the call will do the right thing. But if you declare
  28.  *      malloc as `extern void *malloc()' or `extern char *malloc()'
  29.  *      the call `malloc(sizeof(X))' will not do the right thing. The
  30.  *      same arguement applies to other calls too, where you are
  31.  *      passing sizeof(X) as a parameter to a routine that expects an int
  32.  *      arguement. Please be aware of this when writing/porting code. Of
  33.  *      course when the -mshort flag is not used (32 bit ints) there is
  34.  *      no problem.
  35.  *    - The above behaviour is totally consistent with the Ansi Draft
  36.  *      standard and K&R second edition.
  37.  *
  38.  *    - I am against changing size_t to unsigned int, beacuse that
  39.  *      would imply that no structure can be bigger than 64K
  40.  *      (in the -mshort case when ints are 16 bits) since
  41.  *      you could not take its sizeof(X). That would really cripple
  42.  *      the compiler in my opinion.
  43.  *
  44.  *    - whenver you use mgcc -short now, you have to careful
  45.  *     about using sizeof. If you have
  46.  *        void *malloc(unsigned);
  47.  *        malloc(sizeof(X));
  48.  *    there is no problem, as the compiler will see the prototype
  49.  *    and will cast the second statement to `malloc((unsiged)sizeof(X))'
  50.  *    BUT is you have
  51.  *        extern void *malloc() or extern char *malloc();
  52.  *        malloc(sizeof(X));
  53.  *    then there is a problem beacuse the compiler will push a long
  54.  *    and malloc will see garbage.
  55.  *
  56.  *    - Your comments are of course always welcome.
  57.  *
  58.  */
  59.  
  60. #ifndef _STD_H
  61. #define _STD_H 1
  62.  
  63. #ifdef NO_POOLE_FS
  64. #  ifdef WANT_POOLE_FS
  65. #    undef WANT_POOLE_FS
  66. #  endif
  67. #else
  68. #  ifndef WANT_POOLE_FS
  69. #    define WANT_POOLE_FS
  70. #  endif
  71. #endif
  72.  
  73. #ifdef __STDC__
  74. #ifndef __NO_PROTO__
  75. #ifdef __NO_CONST__
  76.  
  77. #define _CONST /* */
  78. #else
  79. #define _CONST const
  80. #endif
  81.  
  82. void        _cleanup(void);
  83.  
  84. void        abort(void);
  85. int        abs(int);
  86. int        access(_CONST char *, int);
  87. unsigned    alarm(unsigned);
  88. void *        alloca(unsigned long);
  89. int         atexit(void (*)(void));
  90. double        atof(_CONST char *);
  91. int        atoi(_CONST char *);
  92. long        atol(_CONST char *);
  93.  
  94. int        bcmp(_CONST void *, _CONST void *, long);
  95. void        bcopy(_CONST void *, void *, long);
  96. void *        brk(void *);
  97. void         brk2(void);
  98. void        bzero(void *, long);
  99. char *        bsearch(char *, char *, unsigned int, unsigned int,
  100.             int(*)(char *, char *));
  101.  
  102. int        callm1(int, int, int, int, int, _CONST void *,
  103.                _CONST void *, _CONST void *);
  104. int        callm3(int, int, int, _CONST char *);
  105. void *        calloc(unsigned, unsigned);
  106. int        callx(int, int);
  107. void        cfree(void *, unsigned, unsigned);
  108. int        chdir(_CONST char *);
  109. int        chmod(_CONST char *, int);
  110. int        chown(_CONST char *, int, int);
  111. int        chroot(_CONST char *);
  112. int        close(int);
  113. int        creat(_CONST char *, int);
  114. char *        crypt(char *, _CONST char *);
  115. char *        ctime(_CONST long *);
  116. char *        ctermid(char *);
  117. char *        cuserid(char * );
  118.  
  119. int        dup(int);
  120. int        dup2(int, int);
  121.  
  122. void        encrypt(char *, int);
  123. void        endgrent(void);
  124. void        endpwent(void);
  125. int        execl(_CONST char *, _CONST char *, ...);
  126. int        execle(_CONST char *, _CONST char *, ...);
  127. int         execlp(_CONST char *, _CONST char *, ...);
  128. int        execn(_CONST char *);
  129. int        execv(_CONST char *, _CONST char **);
  130. int        execve(_CONST char *, _CONST char **, char **);
  131. int        execvp(_CONST char *, _CONST char **);
  132. void        exit(int);
  133. int        _exit(int);
  134.  
  135. int        ffs(int);
  136. int        fork(void);
  137. void        free(void *);
  138. #if (defined(__MSHORT__) || defined(SHORTLIB))
  139. double        frexp(double, short *);
  140. #else
  141. double        frexp(double, int *);
  142. #endif
  143.  
  144. char *        getcwd( char *, int);
  145. char        getegid(void);
  146. char *        getenv(_CONST char *);
  147. short        geteuid(void);
  148. char        getgid(void);
  149. int        gethostname( char *, int);
  150. char *        getlogin(void);
  151. int        getopt(int, char **, char *);
  152. char *        getpass(_CONST char *);
  153. int        getpid(void);
  154. int        getpgrp(void);
  155. int         getppid(void);
  156. char *        gets(char *);
  157. short        getuid(void);
  158. char *        getwd(char *);
  159.  
  160. char *        index(_CONST char *, int);
  161. int        isatty(int);
  162. char *        itoa(int);
  163.  
  164. int        kill(int, int);
  165.  
  166. double        ldexp(double, int);
  167. #ifdef SHORTLIB
  168. double        __ldexp(double, long);
  169. #endif
  170.  
  171. int        len(_CONST char *);
  172. int        link(_CONST char *, _CONST char *);
  173. int        lock(_CONST char *);
  174. long        lrand(void);
  175. long        seed(long);
  176. char *        lsearch( char *, char *, unsigned *, unsigned,
  177.             int(*)(char *, char *));
  178. char *        lfind( char *, char *, unsigned *, unsigned,
  179.             int(*)(char *, char *));
  180. long        lseek(int, long, int);
  181.  
  182. void *        malloc(unsigned);
  183. void *        memccpy(void *, _CONST void *, int, int);
  184. void *        memchr(_CONST void *, int, int);
  185. int        memcmp(_CONST void *, _CONST void *, int);
  186. void *        memset(void *, int, int);
  187. #ifdef WANT_POOLE_FS
  188. int        mkfifo(_CONST char *name, int);
  189. #endif /* WANT_POOLE_FS */
  190. int        mknod(_CONST char *, int, int);
  191. char *        mktemp(char *);
  192. double        modf(double, double *);
  193. int        mount(_CONST char *, _CONST char *, int);
  194.  
  195. int        nice(int);
  196.  
  197. #ifndef WANT_POOLE_FS
  198.  
  199. #ifdef EMUL_OPEN3
  200. #ifdef __SRC__
  201. extern int    open();
  202. #else
  203. int        open(_CONST char *, int, int);
  204. #endif /* __SRC__ */
  205. #else
  206. #ifdef OPEN3
  207.   /* this is just to fool the prototyping */
  208. int        open(_CONST char *, int, int);
  209. #else
  210. int        open(_CONST char *, int);
  211. #endif /* OPEN3 */
  212. #endif /* EMUL_OPEN3 */
  213.  
  214. #else /* WANT_POOLE_FS */
  215.  
  216. #ifdef __SRC__
  217. int        open(_CONST char *, int, int);
  218. #else
  219. int        open(_CONST char *, int, ...);
  220. #endif /* __SRC__ */
  221. #endif /* WANT_POOLE_FS */
  222.  
  223. int        pause(void);
  224. void        perror(_CONST char *);
  225. int        pipe(int *);
  226. #ifdef __SRC__
  227. int        printf(_CONST char *, int);
  228. #else
  229. int        printf(_CONST char *, ...);
  230. #endif
  231. #ifndef printk
  232. #ifdef __SRC__
  233. void        printk(_CONST char *, int);
  234. #else
  235. void        printk(_CONST char *, ...);
  236. #endif
  237. #endif /* printk */
  238. #ifdef __SRC__
  239. void        prints(_CONST char *, char *);
  240. #else
  241. void        prints(_CONST char *, ...);
  242. #endif
  243. long        ptrace(int, int, long, long);
  244. int        puts(_CONST char *);
  245. int        putenv(char *);
  246.  
  247. void        qsort(void *, unsigned long, unsigned long,
  248.               int(*)(_CONST void *, _CONST void *));
  249.  
  250. int        rand(void);
  251. int        read(int, void *, int);
  252. void *        realloc(void *, unsigned);
  253. int        rename(_CONST char *, _CONST char *);
  254. char *        rindex(_CONST char *, int);
  255.  
  256. void *        sbrk(int);
  257. #ifdef __SRC__
  258. int        scanf(_CONST char *, int);
  259. #else
  260. int        scanf(_CONST char *, ...);
  261. #endif
  262. int        setgid(int);
  263. int        setgrent(void);
  264. int        sethostname( char *, int );
  265. void        setkey(_CONST char *);
  266. int         setpgrp(void);
  267. int        setpwent(void);
  268. int        setuid(int);
  269. unsigned    sleep(unsigned);
  270. #ifdef __SRC__
  271. char *        sprintf(char *, _CONST char *, int);
  272. #else
  273. char *        sprintf(char *, _CONST char *, ...);
  274. #endif
  275. void        srand(long);
  276. #ifdef __SRC__
  277. int        sscanf(_CONST char *, _CONST char *, int);
  278. #else
  279. int        sscanf(_CONST char *, _CONST char *, ...);
  280. #endif
  281. void        std_err(_CONST char *);
  282. int        stime(long *);
  283. char *        strcat(char *, _CONST char *);
  284. int        strcmp(_CONST char *, _CONST char *);
  285. char *        strcpy(char *, _CONST char *);
  286. int        strcspn(_CONST char *, _CONST char *);
  287. char *        strerror(int);
  288. int        strlen(_CONST char *);
  289. char *        strncat(char *, _CONST char *, int);
  290. int        strncmp(_CONST char *, _CONST char *, int);
  291. char *        strncpy(char *, _CONST char *, int);
  292. char *        strpbrk(_CONST char *, _CONST char *);
  293. int        strspn(_CONST char *, _CONST char *);
  294. char *        strstr(_CONST char *, _CONST char *);
  295. char *        strtok(char *, _CONST char *);
  296. void        swab(void *, void *, int);
  297. int        sync(void);
  298. void        sys_abort(void);
  299. void        sys_exec(int, void *, int);
  300. void        sys_fork(int, int, int, unsigned short);
  301. void        sys_fresh(int, void *, unsigned short, unsigned short *,
  302.               unsigned short *); 
  303. void        sys_getsp(int, long *);
  304. void        sys_kill(int, int);
  305. void        sys_newmap(int, void *);
  306. void         sys_nice(int, int);
  307. void        sys_sig(int, int, int(*)());
  308. void        sys_times(int, long *);
  309. int        sys_trace(int, int, long, long *);
  310. void        sys_xit(int, int, unsigned short *, unsigned short *);
  311. int        system(_CONST char *);
  312.  
  313. void        tell_fs(int, int, int, int);
  314. int        tgetent(char *, _CONST char *);
  315. int        tgetflag(_CONST char *);
  316. int        tgetnum(_CONST char *);
  317. char *        tgetstr(_CONST char *, char **);
  318. char *        tgoto(_CONST char *, int, int);
  319. long        time(long *);
  320. char *        tmpname(char *);
  321. char *        tempnam(char *, char *);
  322. int        tolower(int);
  323. int        toupper(int);
  324. int        tputs(_CONST char *, int, int(*)());
  325. char *        ttyname(int);
  326.  
  327. int        umask(int);
  328. int        umount(_CONST char *);
  329. int        unlink(_CONST char *);
  330. void        unlock(_CONST char *);
  331. int        utime(_CONST char *, long *);
  332.  
  333. int        wait(int *);
  334. /* SHOULD it BE ?? int        write(int, void *, unsigned); */
  335. int        write(int, _CONST void *, int);
  336.  
  337. #ifdef __MSHORT__
  338. void *        lmemset(void *, int, long);
  339. int        lmemcmp(_CONST void *, _CONST void *, long);
  340. void *        lmemchr(_CONST void *, int, long);
  341. void *        lmemccpy(void *, _CONST void *, int, long);
  342. void *        lmalloc(unsigned long);
  343. void *        lrealloc(void *, unsigned long);
  344. void *        lcalloc(unsigned long, unsigned long);
  345.  
  346. #endif    /* __MSHORT__ */
  347.  
  348. #endif /* __NO_PROTO__ */
  349.  
  350. #ifndef _CONST
  351. #define _CONST const
  352. #endif
  353.  
  354. #define VOIDSTAR void *
  355.  
  356. #else
  357.  
  358. #define _CONST /* get yourself a modern C compiler! */
  359. #define VOIDSTAR char *
  360.  
  361. #endif    /* __STDC__ */
  362.  
  363. #define SIZET int
  364. #define memcpy(dst, src, size) bcopy(src, dst, (long)size)
  365. #define strchr    index
  366. #define strrchr    rindex
  367.  
  368. #ifndef __MSHORT__
  369. #define lmemset        memset
  370. #define lmemcmp        memcmp
  371. #define lmemchr        memchr
  372. #define lmemccpy    memccpy
  373. #define lmalloc        malloc
  374. #define lrealloc    realloc
  375. #define lcalloc        calloc
  376. #endif
  377.  
  378. #define lbzero        bzero
  379. #define lbcopy        bcopy
  380. #define lbcmp        bcmp
  381.  
  382. #endif    /* _STD_H   */
  383.